Example A-1 : Program to Return Cycle Counter Precision
/***************************************************************************** || || This program makes the value returned by syssgi(SGI_CYCLECNTR_SIZE) || accessible at the command line. The output display can be read, or || tested in a shell script. The value is also returned, so it can || be tested in the $status variable. || *****************************************************************************/ #include <sys/syssgi.h> /* for syssgi(), SGI_QUERY_CYCLECNTR */ #include <stdio.h> int main(int argc, char *argv[]) { unsigned int tbc = syssgi(SGI_CYCLECNTR_SIZE); int arg, quiet = 0; for (arg=1; arg<argc; ++arg) { if (0==strcmp(argv[arg],"-q")) { quiet = 1; } else /* includes case of -h */ { printf("%s [-h | -q]\n",argv[0]); printf("\tReport the precision of the hardware cycle counter.\n"); printf("\tPrecision in bits displayed to stdout unless -q.\n"); printf("\tPrecision in bits returned as status.\n"); return tbc; } } if (!quiet) printf("%d bits in the cycle counter\n",tbc); return tbc; }